package com.douqu.game.auth;

import com.douqu.game.auth.server.SpringContext;
import com.douqu.game.core.factory.LoadFactory;
import com.douqu.game.core.util.LogUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Author : wangzhenfei
 * 2017-07-06 15:36
 */
@EnableTransactionManagement//事务支持,要用事务控制的方法里必须抛出异常才会回滚
@SpringBootApplication
@MapperScan("com.douqu.game.auth.database.mapper")//扫描mapper
public class StartServer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder)
    {
        return applicationBuilder.sources(StartServer.class);
    }


    public static void main(String[] args)
    {
        if (args.length > 0)
        {
            LoadFactory.FIXED_CONFIG_PATH = args[0];
        }
        if (args.length > 1)
        {
            LoadFactory.DYNAMIC_CONFIG_PATH = args[1];
        }

        LogUtils.warn("FIXED_CONFIG_PATH ========> ", LoadFactory.FIXED_CONFIG_PATH);
        LogUtils.warn("DYNAMIC_CONFIG_PATH ==========> ", LoadFactory.DYNAMIC_CONFIG_PATH);

        ApplicationContext applicationContext = SpringApplication.run(StartServer.class, args);
        SpringContext.init(applicationContext);

    }
}
